#include "zygfile.h"


void ZygFile::read(){
    QString path = QDir::currentPath() + "/ZygTimerList.text";
    QFile file(path);

    if(file.open(QIODevice::ReadOnly)){
        QString line = file.readLine();
        do{
            qDebug() << line;
            line = file.readLine();
        }while(line != nullptr);
        file.close();
    }

}


void ZygFile::write(){
    QString path = QDir::currentPath() + "/ZygTimerList.text";
    QFile file(path);

    if(file.open(QIODevice::Truncate |QIODevice::ReadWrite)){
        QString str = ZygTimer::listToFormatString();
//        qDebug() << "写入";
//        qDebug() << str;
        std::string reslult = str.toStdString();
        file.write(reslult.c_str());
        file.flush();
        file.close();
    }
}
